package com.xxc.hs.bean;

import android.util.Log;

import cn.com.newland.nle_sdk.requestEntity.SignIn;
import cn.com.newland.nle_sdk.responseEntity.User;
import cn.com.newland.nle_sdk.responseEntity.base.BaseResponseEntity;
import cn.com.newland.nle_sdk.util.CloudService;
import cn.com.newland.nle_sdk.util.CloudServiceListener;

public class CloudInfo {

    //云服务登录
    private static final String URL = "http://api.nlecloud.com";        //云平台地址
    private static final String ACCOUNT = "15871852036";                //用户名
    private static final String PASSWORD = "123456789";                 //密码


    //云服务项目和设备ID
    public static final int ProjectId = 1229492;                        //项目ID
    public static final int GatewayId = 1296244;                        //中心网关ID
    public static final int SerialPortId = 1296299;                     //串口终端ID

    //云服务设备标识名
    //网关设备
    public static final String UHF = "UHF";                             //UHF
    public static final String LASER = "m_laser";                       //激光
    public static final String SMOKE = "m_smoke";                       //烟雾
    public static final String FIRE = "m_fire";                         //火焰
    public static final String TEMP = "m_temp";                         //温度
    public static final String HUM = "m_hum";                           //湿度
    public static final String DOORBACK = "m_pushrod_back";             //电动推杆回退
    public static final String ALARM = "m_lamp";                        //报警灯
    public static final String DOORPUT = "m_pushrod_put";               //电动推杆前进
    public static final String FAN = "m_fan";                           //风扇


    //串口终端设备
    public static final String PH = "ph";                               //PH
    public static final String WATERTEMP = "waterTemp";                 //水温
    public static final String DISSOLVED = "ryl";                       //溶氧量
    public static final String TURBIDITY = "zd";                        //浊度
    public static final String WATERLEVEL = "waterLevel";               //水位
    public static final String YULV = "yl";                             //余氯
    public static final String SUN = "dianliang";                       //太阳能电量


    //水产控制器设备
    public static final String SHUIBENG = "shuibeng";                   //水泵
    public static final String TOULIAOJI = "touliaoji";                 //投料机
    public static final String GUOLV = "gulvqi";                       //过滤器
    public static final String ZENGYANGBENG = "zengyangj";             //增氧泵


    private static CloudService cloudService;

    public static CloudService getCloudService() {
        return cloudService;
    }

    public static void setCloudService() {
        cloudService = new CloudService(URL);
        new Thread(new Runnable() {
            @Override
            public void run() {
                cloudService.signIn(new SignIn(ACCOUNT, PASSWORD), new CloudServiceListener<BaseResponseEntity<User>>() {
                    @Override
                    protected void onResponse(BaseResponseEntity<User> userBaseResponseEntity) {
                        if (userBaseResponseEntity.getStatus() != 0) {
                            Log.e("cloud", "云服务初始化失败");
                        }
                        Log.e("cloud", "云服务初始化成功");
                        cloudService.setAccessToken(userBaseResponseEntity.getResultObj().getAccessToken());
                    }
                });
            }
        }).start();
    }


}